/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.util.List;

import core.objects.BookLoan;

/**
 *
 * @author abadi
 */
public class JPanelLoansList extends javax.swing.JPanel {

    private boolean isLoanedFromMe;
    private List<BookLoan> bookLoansList;
    /**
     * Creates new form JPanelLoansList
     */
    public JPanelLoansList(boolean isLoanedFromMe, List<BookLoan> bookLoansList) {
        this.isLoanedFromMe = isLoanedFromMe;
        this.bookLoansList = bookLoansList;
        initComponents();
        if (!isLoanedFromMe) jLabelHeader.setText(" Loaned  To  Me ");
        initLoansList();
    }

    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this
     * code. The content of this method is always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jLabelHeader = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jPanelLoans = new javax.swing.JPanel();

        setLayout(new java.awt.BorderLayout());

        jPanel3.setBackground(new java.awt.Color(51, 153, 255));

        jLabelHeader.setBackground(new java.awt.Color(51, 153, 255));
        jLabelHeader.setFont(new java.awt.Font("Trebuchet MS", 1, 24)); // NOI18N
        jLabelHeader.setForeground(new java.awt.Color(153, 255, 153));
        jLabelHeader.setText("Loaned From Me");

        jPanel5.setBackground(new java.awt.Color(66, 168, 255));
        jPanel5.setLayout(new java.awt.BorderLayout());

        jScrollPane2.setBackground(new java.awt.Color(66, 168, 255));
        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        jPanelLoans.setBackground(new java.awt.Color(66, 168, 255));
        jPanelLoans.setLayout(new javax.swing.BoxLayout(jPanelLoans, javax.swing.BoxLayout.Y_AXIS));
        jScrollPane2.setViewportView(jPanelLoans);

        jPanel5.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabelHeader)
                .addGap(5, 5, 5)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(90, 90, 90)
                .addComponent(jLabelHeader))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
        );

        add(jPanel3, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JLabel jLabelHeader;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelLoans;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables

    private void initLoansList() {
        for (BookLoan bl: bookLoansList){
            jPanelLoans.add(new JPanelLoanLine(bl, isLoanedFromMe));
        }
    }
}
